package Eyjafjalla.action;

import Eyjafjalla.patch.CloudPatch;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;

public class ChorusAction extends AbstractGameAction {
    public ChorusAction(int amt,boolean isFire,int extraAmt){
        this(amt,isFire,extraAmt,false);
    }

    public ChorusAction(int amt,boolean isFire,int extraAmt,boolean hand){
        this.amount = amt;
        this.isFire = isFire;
        this.hand = hand;
        this.extra = extraAmt;
    }

    boolean hand;
    boolean isFire;
    int extra;

    @Override
    public void update() {
        if(amount<=0){
            this.isDone = true;
            return;
        }
        if(!hand){
            for(AbstractCard card: CloudPatch.cloudGroup.group){
                int aAmount = amount;
                if(isFire&&CloudPatch.CloudField.isFire.get(card)){
                    aAmount+=extra;
                }
                if(card.baseDamage>=0){
                    card.baseDamage += aAmount;
                }
                if(card.baseBlock>=0){
                    card.baseBlock += aAmount;
                }
                card.applyPowers();
                card.flash();
            }
        }
        else {
            for(AbstractCard card: AbstractDungeon.player.hand.group){
                int aAmount = amount;
                if(isFire&&CloudPatch.CloudField.isFire.get(card)){
                    aAmount+=extra;
                }
                if(card.baseDamage>=0){
                    card.baseDamage += aAmount;
                }
                if(card.baseBlock>=0){
                    card.baseBlock += aAmount;
                }
                card.applyPowers();
                card.flash();
            }
        }
        this.isDone = true;
    }
}
